TMP_Sprite.shader (2307B)
1 Shader "TextMeshPro/Sprite" 2 { 3 Properties 4 { 5 _MainTex ("Sprite Texture", 2D) = "white" {} 6 _Color ("Tint", Color) = (1,1,1,1) 7 8 _StencilComp ("Stencil Comparison", Float) = 8 9 _Stencil ("Stencil ID", Float) = 0 10 _StencilOp ("Stencil Operation", Float) = 0 11 _StencilWriteMask ("Stencil Write Mask", Float) = 255 12 _StencilReadMask ("Stencil Read Mask", Float) = 255 13 14 _ColorMask ("Color Mask", Float) = 15 15 _ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767) 16 17 [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0 18 } 19 20 SubShader 21 { 22 Tags 23 { 24 "Queue"="Transparent" 25 "IgnoreProjector"="True" 26 "RenderType"="Transparent" 27 "PreviewType"="Plane" 28 "CanUseSpriteAtlas"="True" 29 } 30 31 Stencil 32 { 33 Ref [_Stencil] 34 Comp [_StencilComp] 35 Pass [_StencilOp] 36 ReadMask [_StencilReadMask] 37 WriteMask [_StencilWriteMask] 38 } 39 40 Cull Off 41 Lighting Off 42 ZWrite Off 43 ZTest [unity_GUIZTestMode] 44 Blend SrcAlpha OneMinusSrcAlpha 45 ColorMask [_ColorMask] 46 47 Pass 48 { 49 CGPROGRAM 50 #pragma vertex vert 51 #pragma fragment frag 52 53 #include "UnityCG.cginc" 54 #include "UnityUI.cginc" 55 56 #pragma multi_compile __ UNITY_UI_CLIP_RECT 57 #pragma multi_compile __ UNITY_UI_ALPHACLIP 58 59 struct appdata_t 60 { 61 float4 vertex : POSITION; 62 float4 color : COLOR; 63 float2 texcoord : TEXCOORD0; 64 }; 65 66 struct v2f 67 { 68 float4 vertex : SV_POSITION; 69 fixed4 color : COLOR; 70 half2 texcoord : TEXCOORD0; 71 float4 worldPosition : TEXCOORD1; 72 }; 73 74 fixed4 _Color; 75 fixed4 _TextureSampleAdd; 76 float4 _ClipRect; 77 78 v2f vert(appdata_t IN) 79 { 80 v2f OUT; 81 OUT.worldPosition = IN.vertex; 82 OUT.vertex = UnityObjectToClipPos(OUT.worldPosition); 83 84 OUT.texcoord = IN.texcoord; 85 86 #ifdef UNITY_HALF_TEXEL_OFFSET 87 OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1); 88 #endif 89 90 OUT.color = IN.color * _Color; 91 return OUT; 92 } 93 94 sampler2D _MainTex; 95 96 fixed4 frag(v2f IN) : SV_Target 97 { 98 half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color; 99 100 #if UNITY_UI_CLIP_RECT 101 color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); 102 #endif 103 104 #ifdef UNITY_UI_ALPHACLIP 105 clip (color.a - 0.001); 106 #endif 107 108 return color; 109 } 110 ENDCG 111 } 112 } 113 }